/* 全局 Flexbox 布局 - 解决所有滚动条问题 */
html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* 防止最外层出现滚动条 */
}

#root {
  display: flex;
  flex-direction: column;
}

/* 聊天页面样式 - 使用 Flexbox 布局 */
.chat-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #f5f5f5;
  overflow: hidden; /* 确保聊天布局不出现滚动条 */
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  background-color: #fff;
  border-radius: 8px;
  margin: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden; /* 确保主容器不出现滚动条 */
  min-height: 0; /* 重要：允许 flex 子元素收缩 */
}

/* 聊天头部 - 固定高度，不参与 flex 伸缩 */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  flex: 0 0 auto; /* 固定高度，不伸缩 */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-text {
  font-size: 12px;
  color: #8c8c8c;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-selector {
  background-color: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.agent-selector:hover {
  border-color: #1890ff;
}

.agent-selector:focus {
  outline: none;
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}



/* 智能体选择器弹窗 */
.agent-selector-modal .ant-modal-content {
  border-radius: 12px;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px 0;
}

.agent-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  border: 2px solid #f0f0f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #fff;
}

.agent-card:hover {
  border-color: #1890ff;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
  transform: translateY(-2px);
}

.agent-card.selected {
  border-color: #1890ff;
  background-color: #f6ffed;
}

.agent-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.agent-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.agent-desc {
  font-size: 12px;
  color: #8c8c8c;
  text-align: center;
  line-height: 1.4;
}

/* 消息容器 - 使用 Flexbox 实现完美滚动 */
.messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 隐藏溢出，由内部处理 */
  background-color: #fafafa;
  position: relative; /* 为绝对定位的滚动容器提供参考 */
  min-height: 0; /* 重要：允许 flex 子元素收缩 */
}

.messages-list {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 消息样式 */
.message-wrapper {
  display: flex;
  margin-bottom: 16px;
}

.message-wrapper.user {
  justify-content: flex-end;
}

.message-wrapper.agent {
  justify-content: flex-start;
}

.message-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 70%;
}

.message-wrapper.user .message-content {
  flex-direction: row-reverse;
}

.message-avatar {
  flex-shrink: 0;
}

.message-bubble {
  background-color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  word-wrap: break-word;
  word-break: break-word; /* 确保长单词也能换行 */
  max-width: 100%;
  overflow-wrap: break-word; /* 现代浏览器的换行属性 */
}

.message-wrapper.user .message-bubble {
  background-color: #1890ff;
  color: #fff;
}

.message-wrapper.agent .message-bubble {
  background-color: #fff;
  border: 1px solid #e8e8e8;
}

.message-header {
  margin-bottom: 8px;
}

.message-name {
  font-size: 12px;
  font-weight: 500;
  color: #8c8c8c;
}

.message-wrapper.user .message-name {
  color: rgba(255, 255, 255, 0.8);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.message-time {
  font-size: 11px;
  color: #bfbfbf;
  text-align: right;
}

.message-wrapper.user .message-time {
  color: rgba(255, 255, 255, 0.6);
}

/* 思考过程按钮激活状态 */
.input-btn.active {
  border-color: #52c41a;
  color: #52c41a;
  background-color: #f6ffed;
}

.input-btn.active:hover {
  border-color: #73d13d;
  color: #73d13d;
  background-color: #f6ffed;
}

.input-btn.inactive {
  border-color: #ff7875;
  color: #ff7875;
  background-color: #fff2f0;
}

.input-btn.inactive:hover {
  border-color: #ff9c9c;
  color: #ff9c9c;
  background-color: #fff2f0;
}

/* 输入区域 - 固定在底部，不参与滚动 */
.input-container {
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
  background-color: #fff;
  flex: 0 0 auto; /* 固定高度，不伸缩 */
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-left-buttons {
  display: flex;
  gap: 8px;
}

.input-btn {
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  color: #666;
  background-color: #fff;
}

.input-btn:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.message-input {
  border-radius: 20px;
  border: 1px solid #d9d9d9;
  padding: 8px 16px;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  transition: all 0.3s;
}

.message-input:focus {
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.input-right-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.auto-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  color: #666;
  position: relative;
}

.auto-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background-color: #ff4d4f;
  border-radius: 50%;
}

.send-button {
  border-radius: 20px;
  height: 36px;
  padding: 0 20px;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .chat-main {
    margin: 8px;
    border-radius: 4px;
  }
  
  .chat-header {
    padding: 12px 16px;
  }
  
  .messages-list {
    padding: 12px 16px;
  }
  
  .input-container {
    padding: 12px 16px;
  }
  
  .message-content {
    max-width: 85%;
  }
}

/* 滚动条样式 - 只针对消息列表 */
.messages-list::-webkit-scrollbar-track {
  background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.messages-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
  background-clip: content-box;
}

/* 确保所有容器都没有滚动条 */
.chat-layout,
.chat-main,
.messages-container,
.input-container,
.chat-header {
  overflow: hidden;
}

/* 强制隐藏所有可能的滚动条 */
.chat-layout::-webkit-scrollbar,
.chat-main::-webkit-scrollbar,
.messages-container::-webkit-scrollbar,
.input-container::-webkit-scrollbar,
.chat-header::-webkit-scrollbar {
  display: none;
}

/* 确保消息列表是唯一的滚动区域 */
.messages-list {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* 加载状态样式 */
.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

/* 覆盖 Ant Design 组件的默认滚动条 */
.ant-card,
.ant-modal,
.ant-drawer,
.ant-tabs-content {
  overflow: hidden !important;
}

/* 确保输入框不会产生滚动条 */
.ant-input,
.ant-input-textarea {
  overflow: hidden !important;
}

/* 全局滚动条样式重置 */
* {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

*::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* 只允许消息列表显示滚动条 */
.messages-list {
  scrollbar-width: auto;
  -ms-overflow-style: auto;
}

.messages-list::-webkit-scrollbar {
  display: block;
  width: 8px;
}

/* 右侧工作空间样式 */
.workspace-panel {
  width: 420px;
  border-left: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

.workspace-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
}

.workspace-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px;
}

.workspace-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.workspace-pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
}

/* 折叠把手 */
.workspace-collapsed-handle {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: #fff;
  border-left: 1px solid #f0f0f0;
  color: #999;
}

.workspace-collapsed-handle:hover {
  color: #333;
}

@media (max-width: 992px) {
  .workspace-panel {
    display: none;
  }
}

 